package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.PostBean;
import com.project.mapper.IPostMapper;
import com.project.service.IPostService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
@Service
@Transactional
public class IPostServiceImpl implements IPostService2 {
    @Autowired
    private IPostMapper mapper;
    @Override
    public PageInfo<PostBean> findByItem(int typeId, int pageNnm, String title, String acc, LocalDateTime start, LocalDateTime end) {
        PageHelper.startPage(pageNnm,PAFESIZE);
        PageInfo<PostBean> info = PageInfo.of(mapper.findByItem(typeId,title,acc,start,end));
        return info;
    }

    @Override
    public void add(PostBean post) {
        mapper.add(post);

    }

    @Override
    public PostBean findById(int id) {
        return mapper.findById(id) ;
    }
}
